


************ subsides
import excel "operating aid.xlsx", sheet("data") firstrow clear

reshape long drift_, i(outlet) j(year)
gen subsidy_bin = 0
replace subsidy_bin = 1 if drift_ > 0 & !missing(drift_)
rename drift_ subsidy_amount
replace subsidy_amount = 0 if missing(subsidy_amount)

save "subsidies_temp.dta", replace






************ ownership
import excel "outlets owners areas editions.xlsx", sheet("data") firstrow clear

keep if retriever == "yes"
keep outlet owner owner_note entry_exit

expand 2, gen(add)
gen tm = tm(2014m1)
format tm %tm
replace tm = tm(2022m12) if add == 1
drop add

encode outlet, gen(outlet_id)
tsset outlet_id tm
tsfill, full

carryforward outlet owner owner_note, replace
bysort outlet (tm): carryforward entry_exit, replace


* entry / exits
drop if outlet == "Folket" & tm > tm(2015m6)
drop if outlet == "Jämtlands Tidning" & tm < tm(2015m5)
drop if outlet == "Laholms Tidning" & tm > tm(2018m10)
drop if outlet == "Östran" & tm > tm(2019m11)
drop if outlet == "Länstidningen Värmlandsbygden" & tm > tm(2022m9)


* ownership changes
replace owner = "Pukslagaren i Helsingborg" if ///
 owner_note == "2014m1-2014m6 Pukslagaren i Helsingborg; 2014m7-2022m12 Bonnier" & ///
 tm <= tm(2014m6)
 
replace owner = "Bonnier" if ///
 owner_note == "2014m1-2014m6 Pukslagaren i Helsingborg; 2014m7-2022m12 Bonnier" & ///
 tm >= tm(2014m7)

 
replace owner = "Promedia" if ///
 owner_note == "2014m1-2015m12 Promedia; 2016m1-2019m1 Mittmedia; 2019m2-2022m12 Bonnier" & ///
 tm <= tm(2015m12)
 
replace owner = "Mittmedia" if ///
 owner_note == "2014m1-2015m12 Promedia; 2016m1-2019m1 Mittmedia; 2019m2-2022m12 Bonnier" & ///
 tm >= tm(2016m1) & tm <= tm(2019m1)
 
replace owner = "Bonnier" if ///
 owner_note == "2014m1-2015m12 Promedia; 2016m1-2019m1 Mittmedia; 2019m2-2022m12 Bonnier" & ///
 tm >= tm(2019m2)

 
replace owner = "Nya Wermlands-Tidningen" if ///
 owner_note == "2014m1-2016m12 Nya Wermlands-Tidningen; 2017m1-2022m12 NTM-koncernen" & ///
 tm <= tm(2016m12)
 
replace owner = "NTM-koncernen" if ///
 owner_note == "2014m1-2016m12 Nya Wermlands-Tidningen; 2017m1-2022m12 NTM-koncernen" & ///
 tm >= tm(2017m1)
 
 
replace owner = "Socialdemokraterna" if ///
 owner_note == "2014m1-2016m12 Socialdemokraterna; 2017m1-2022m12 Nya Wermlands-Tidningen" & ///
 tm <= tm(2016m12)
 
replace owner = "Nya Wermlands-Tidningen" if ///
 owner_note == "2014m1-2016m12 Socialdemokraterna; 2017m1-2022m12 Nya Wermlands-Tidningen" & ///
 tm >= tm(2017m1)


replace owner = "Värmlands Folkblad Drift AB" if ///
 owner_note == "2014m1-2017m2 Värmlands Folkblad Drift AB; 2017m3-202m12 Nya Wermlands-Tidningen" & ///
 tm <= tm(2017m2)

replace owner = "Nya Wermlands-Tidningen" if ///
 owner_note == "2014m1-2017m2 Värmlands Folkblad Drift AB; 2017m3-202m12 Nya Wermlands-Tidningen" & ///
 tm >= tm(2017m3)
 
 
replace owner = "Swepress Media" if ///
 owner_note == "2014m1-2018m1 Swepress Media; 2018m2-2019m4 NTM-koncernen" & ///
 tm <= tm(2018m1)
 
replace owner = "NTM-koncernen" if ///
 owner_note == "2014m1-2018m1 Swepress Media; 2018m2-2019m4 NTM-koncernen" & ///
 tm >= tm(2018m2)
 

replace owner = "Hörlings Lidköpingspress AB" if ///
 owner_note == "2014m1-2018m12 Hörlings Lidköpingspress AB; 2019m1-2022m12 Nya Wermlands-Tidningen" & ///
 tm <= tm(2018m12)
 
replace owner = "Nya Wermlands-Tidningen" if ///
 owner_note == "2014m1-2018m12 Hörlings Lidköpingspress AB; 2019m1-2022m12 Nya Wermlands-Tidningen" & ///
 tm >= tm(2019m1)
 

replace owner = "Eskilstuna-Kurirens stiftelse" if ///
 owner_note == "2014m1-2018m9 Eskilstuna-Kurirens stiftelse; 2018m10-2019m4 NTM-koncernen" & ///
 tm <= tm(2018m9)
 
replace owner = "NTM-koncernen" if ///
 owner_note == "2014m1-2018m9 Eskilstuna-Kurirens stiftelse; 2018m10-2019m4 NTM-koncernen" & ///
 tm >= tm(2018m10) 
 
 
replace owner = "Eskilstuna-Kurirens stiftelse" if ///
 owner_note == "2014m1-2018m9 Eskilstuna-Kurirens stiftelse; 2018m10-2022m12 NTM-koncernen" & ///
 tm <= tm(2018m9)
 
replace owner = "NTM-koncernen" if ///
 owner_note == "2014m1-2018m9 Eskilstuna-Kurirens stiftelse; 2018m10-2022m12 NTM-koncernen" & ///
 tm >= tm(2018m10) 
 
 
replace owner = "Mittmedia" if ///
 owner_note == "2014m1-2019m1 Mittmedia; 2019m2-2022m12 Bonnier" & ///
 tm <= tm(2019m1)
 
replace owner = "Bonnier" if ///
 owner_note == "2014m1-2019m1 Mittmedia; 2019m2-2022m12 Bonnier" & ///
 tm >= tm(2019m2) 
 
 
replace owner = "Ortstidningar i Väst" if ///
 owner_note == "2014m1-2019m11 Ortstidningar i Väst; 2019m12-2022m12 PNV Media" & ///
 tm <= tm(2019m11) 
 
replace owner = "PNV Media" if ///
 owner_note == "2014m1-2019m11 Ortstidningar i Väst; 2019m12-2022m12 PNV Media" & ///
 tm >= tm(2019m12)  
 
 
replace owner = "Stampen" if ///
 owner_note == "2014m1-2019m4 Stampen; 2019m5-2022m12 PNV Media" & ///
 tm <= tm(2019m4) 
 
replace owner = "PNV Media" if ///
 owner_note == "2014m1-2019m4 Stampen; 2019m5-2022m12 PNV Media" & ///
 tm >= tm(2019m5) 
 
 
replace owner = "WM Media" if ///
 owner_note == "2014m1-2019m9 WM Media; 2019m10-2022m12 PNV Media" & ///
 tm <= tm(2019m9)
 
replace owner = "PNV Media" if ///
 owner_note == "2014m1-2019m9 WM Media; 2019m10-2022m12 PNV Media" & ///
 tm >= tm(2019m10) 
 
 
replace owner = "Hall Media" if ///
 owner_note == "2014m1-2020m2 Hall Media; 2020m3-2022m12 Bonnier" & ///
 tm <= tm(2020m2) 
 
replace owner = "Bonnier" if ///
 owner_note == "2014m1-2020m2 Hall Media; 2020m3-2022m12 Bonnier" & ///
 tm >= tm(2020m3)  
 
 
replace owner = "Tidningar i Norr AB" if ///
 owner_note == "2014m1-2021m2 Tidningar i Norr AB; 2021m3-2022m12 VK Media" & ///
 tm <= tm(2021m2) 
  
replace owner = "VK Media" if ///
 owner_note == "2014m1-2021m2 Tidningar i Norr AB; 2021m3-2022m12 VK Media" & ///
 tm >= tm(2021m3) 
 
 
replace owner = "Skåne Tidningsägareföreningen" if ///
 owner_note == "2014m1-2021m6 Skåne Tidningsägareföreningen; 2021m7-2022m12 Bonnier" & ///
 tm <= tm(2021m6) 
 
replace owner = "Bonnier" if ///
 owner_note == "2014m1-2021m6 Skåne Tidningsägareföreningen; 2021m7-2022m12 Bonnier" & ///
 tm >= tm(2021m7)  
 
 
replace owner = "Skåne Tidningsägareföreningen" if ///
 owner_note == "2014m1-2021m6 Skåne Tidningsägareföreningen; 2021m7-2022m12 Gota Media" & ///
 tm <= tm(2021m6) 
 
replace owner = "Gota Media AB" if ///
 owner_note == "2014m1-2021m6 Skåne Tidningsägareföreningen; 2021m7-2022m12 Gota Media" & ///
 tm >= tm(2021m7)  
 
* merge with circulation data
gen year = yofd(dofm(tm))
merge m:1 year outlet using "circulation data.dta" 
keep if _merge == 3

drop _merge owner_note entry_exit outlet_id

* gen indicator for post-acquisition
bysort outlet owner (tm): gen post = _n == 1
bysort outlet (tm): replace post = sum(post)
replace post = 0 if post == 1
replace post = 1 if post > 1

bysort outlet (tm): egen acquired = max(post)

gen status = 1
replace status = 2 if acquired == 1 & post == 0
replace status = 3 if acquired == 1 & post == 1

gen post_acquired = post*acquired

* merge subsidies
merge m:1 outlet year using "subsidies_temp.dta"
drop if _merge == 2
drop _merge
erase "subsidies_temp.dta"


* tag existing newspaper of acquiring owner
bysort owner tm (outlet): egen merger_involved_post = max(post_acquired)
replace merger_involved_post = 0 if post_acquired == 1
 
encode outlet, gen(outlet_id)
encode owner, gen(owner_id)

* tag existing papers of acquiring owner after acquisition
gen post_merged = 0
replace post_merged = 1 if post_acquired == 1 | merger_involved_post == 1

gen date = dofm(tm)
gen month = month(date)
drop date

gen pandemic = 0
replace pandemic = 1 if tm >= tm(2020m3)

gen election_1m = 0
replace election_1m = 1 if tm == tm(2014m9) | tm == tm(2018m9) | tm == tm(2022m9)
gen election_3m = 0
replace election_3m = 1 if tm == tm(2014m7) | tm == tm(2014m8) | tm == tm(2014m9) | ///
                               tm == tm(2018m7) | tm == tm(2018m8) | tm == tm(2018m9) | ///
							   tm == tm(2022m7) | tm == tm(2022m8) | tm == tm(2022m9)

					   				
* rescale subsidies in MSEK
replace subsidy_amount = subsidy_amount/1000000


keep outlet owner tm year post subscribers acquired post_acquired subsidy_amount ///
 outlet_id owner_id post_merged month pandemic election_3m

save "newspaper month data.dta", replace
 

 

 
* determine concentration ratios
use "newspaper month data.dta", clear
bysort tm: egen total_subscriptions = sum(subscribers)
bysort tm owner: egen owner_subscriptions = sum(subscribers)
gen owner_sub_share = owner_subscriptions/total_subscriptions
collapse (mean) owner_sub_share total_subscriptions, by(owner tm)
 
gsort tm -owner_sub_share
by tm: egen top3 = total(owner_sub_share*(_n<=3))
by tm: egen top4 = total(owner_sub_share*(_n<=4))
by tm: egen top5 = total(owner_sub_share*(_n<=5))

sum top3 if tm == tm(2014m1)
sum top4 if tm == tm(2014m1)
sum top5 if tm == tm(2014m1)
 
sum top3 if tm == tm(2022m12)
sum top4 if tm == tm(2022m12)
sum top5 if tm == tm(2022m12) 
 
collapse (mean) top3 top4 top5, by(tm)

save "CRs.dta", replace
 
 
 

 
* HHI
use "newspaper month data.dta", clear

collapse (sum) subscribers, by(owner tm)

bysort tm: egen total_subscriptions = sum(subscribers)
bysort tm owner: egen owner_subscriptions = sum(subscribers)
gen o_sh = owner_subscriptions/total_subscriptions

bysort tm: gen o_count = _N

encode(owner), gen(owner_id)
drop owner subscribers total_subscriptions owner_subscriptions
reshape wide o_sh, i(tm) j(owner_id)

foreach var of varlist o_sh* {
	replace `var' = 0 if missing(`var')
}	  
	  
gen hhi = 100*(o_sh1^2 + o_sh2^2 + o_sh3^2 + o_sh4^2 + o_sh5^2 + o_sh6^2 + ///
               o_sh7^2 + o_sh8^2 + o_sh9^2 + o_sh10^2 + o_sh11^2 + o_sh12^2 + ///
			   o_sh13^2 + o_sh14^2 + o_sh15^2 + o_sh16^2 + o_sh17^2 + o_sh18^2 + ///
			   o_sh19^2 + o_sh20^2 + o_sh21^2 + o_sh22^2 + o_sh23^2 + o_sh24^2 + ///
			   o_sh25^2 + o_sh26^2 + o_sh27^2)
 
drop o_sh*
 
save "hhi.dta", replace
 
 

 
use "newspaper month data.dta", clear
bysort owner tm: gen n_count = _N
collapse (mean) n_count, by(tm)


merge 1:1 tm using "hhi.dta"
drop _merge

merge 1:1 tm using "CRs.dta"
drop _merge

drop n_count o_count

label variable tm "Year and month"
label variable hhi "Herfindahl-Hirschman Index of owners' circulation shares"
label variable top3 "Combined circulation share of top 3 owners"
label variable top4 "Combined circulation share of top 4 owners"
label variable top5 "Combined circulation share of top 5 owners"

sort tm
save "consolidation measures.dta", replace
erase "hhi.dta"
erase "CRs.dta"

 
 
 
 


 
 
 